<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="css/lib/bootstrap.min.css"/>
		<script src="js/lib/jquery-1.11.0.js"></script>
		<script src="js/lib/bootstrap.min.js"></script>
		<script src="js/lib/angular.min.js"></script>
		<script src="js/base.js" type="text/javascript" charset="utf-8"></script>
	</head>
	 <style>
	 	body{
			font-size:12px;
		}
	 	table,
		
			td {
				border: 1px solid #fff;
				border-collapse: collapse;
				padding: 5px;
				vertical-align: middle !important;
			}	
		table td:nth-child(even){
			
		}
		table tr:nth-child(2){
			background-color:#f1f1f1;
		}
		input{
			width:280px;
		}
		span{
			width:20px;color:red;display:inline-block;text-align:center;
		}
		#sho{
			width:300px;
			height:50px;
			background:#d9534f;
			opacity:0.8;
			border-radius:8px;
			color:#fff;
			text-align: center;
			font-size:30px;
			position: absolute;
			top:0px;
			left:550px;
			display:none;
		}

	 </style>
	<body ng-app="myApp" ng-controller="customersCtrl">
		<div class="">
			<div id="sho"></div>
		
			<div style="padding:15px 5px 0px 5px;border:3px solid #ccc;margin-bottom:15px">
			<table class="table table-hover">
				
				<tbody>
					<tr>
						<th colspan="9" style="font-size:26px;color:#337ab7">三级分销产品列表：</th>
					</tr>
					<tr>
						<td colspan="3" class="text-center" style="font-size:16px;">品牌编号查询三级分销产品：</td>
						<td colspan="3">
							<!-- <select style="width:280px" class="form-control" ng-model="input" ng-change="mm()">
								<option value="">请选择</option>
								<option ></option>
							</select> -->
							<input class="form-control" id="op" type="text" ng-model="input"  style="display:block">
						</td>
						<td colspan="9">
							<button name="name0" style="display: block;margin:0 auto" id="btn" class="btn btn-danger" ng-click="query()">删除产品</button>
						</td>
					</tr>
					<tr style="font-size:16px;background:rgb(0, 122, 255);color:#fff">
						<td style="width:50px;" class="text-center">序号</td>
						<td class="text-center">品牌ID</td>
						<td class="text-center">产品ID</td>
						<!-- <td class="text-center">折扣</td> -->
						<td class="text-center">等级</td>
						<td class="text-center">金额</td>
						<td class="text-center">名称</td>
						<td class="text-center">展示方式</td>
						<td class="text-center">日期</td>
						<td class="text-center">操作</td>
						<!-- <td class="text-center">操作</td> -->
					</tr>
					<tr id="show" ng-repeat="item in items">
						<td class="text-center">{{$index+1}}</td>
						<td class="text-center">{{item.brandId}}</td>
						<td class="text-center">{{item.id}}</td>
						<!-- <td class="text-center">{{item.discount}}</td> -->
						<td class="text-center">{{item.grade}}</td>
						<td class="text-center">{{item.money | currency:"￥ "}}</td>
						<td class="text-center">{{item.name}}</td>
						<td class="text-center">{{item.trueFalseBuy | modify3:item.trueFalseBuy}}</td>						
						<!--<td class="text-center">{{item.remark}}</td>-->
						<td class="text-center">{{item.createTime}}</td>
						<!-- <td>
							<a href="addrata.html"><button class="btn btn-default" style="display:block;margin:0 auto" id="bian" ng-click="hk(item)">费率变更</button></a>
						</td> -->
						<td>
							<a href="addrata.html" ng-click="hk(item)" style="display:block;margin:0 auto;text-align:center;">变更</a>
						</td>
						<!-- <td>
							<a href="addrata.html"><button class="btn btn-default" style="display:block;margin:0 auto" id="bian" ng-click="hk(item)">费率变更</button></a>
						</td> -->
					</tr>
					<tr>
						<td  colspan="9">
							<p style="color:red;display:inline;">
								PS:用户更新到当前产品级别后，会自动获取产品对应的费率，请务必提前设置好产品费率后再给用户变更级别;级别变更可通过分享，购买，或者在<span style="color:#3399FF;display:inline">会员管理-->变更</span>处手动设置
							</p>
						</td>
					</tr>
				</tbody>
			</table>		
		</div>
		</div>
	</body>
	<script>
		$(function(){
			var brandname = sessionStorage.getItem(key=100);
			console.log(brandname);
			$('#op').val(brandname);
		})
	</script>
	<script>
		var app = angular.module('myApp', []);
	   /*自定义过滤器   1*/
		app.filter("modify",function(){
			return function(input,param){
				if(param == 0){
					return param = "充值"
				}
				if(param == 1){
					return param = "支付"
				}
				if(param == 2){
					return param = "提现"
				}
				if(param == 3){
					return param = "退单"
				}
				input = param
				return input
			}
		})
		/*自定义过滤器   2*/
		app.filter("modify2",function(){
			return function(input,param){
				if(param == 0){
					return param = "待完成"
				}
				if(param == 1){
					return param = "成功"
				}
				if(param == 2){
					return param = "取消"
				}
				input = param
				return input
			}
		})
		/*自定义过滤器   3*/
		app.filter("modify3",function(){
			return function(input,param){
				if(param == 0){
					return param = "【线上购买】显示价格"
				}
				if(param == 1){
					return param = "【联系客服】显示价格"
				}
				if(param == 2){
					return param = "【线上购买】隐藏价格"
				}
				if(param == 3){
					return param = "【联系客服】隐藏价格"
				}
				if(param == 4){
					return param = "【隐藏产品】"
				}
				input = param
				return input
			}
		})
        app.controller('customersCtrl', function($scope, $http ){        	
        	/*按品牌查询所有三级分销产品*/
        		
        			var brand = sessionStorage.getItem(key=3);
        			var token = sessionStorage.getItem(1)
        			console.log(brand)
        			
        					$http({
								method:'GET',					
								url: window.baseUrl+"user/thirdlevel/prod/brand/"+brand + '/' + token,
							}).then(function successCallback(data){
								console.log("查询所有三级分销产品成功...")
								console.log(data.data)
								if(data.data.result.length==0){
									$scope.items = ""
									alert("暂无数据")	
								}else{
									$scope.items = data.data.result
								}
							}, function errorCallback(data) {
									console.log("查询所有三级分销产品失败...")
							     	console.log(data)
							});
        			
        			$scope.input = ""  
        		
        	$scope.query = function(){ 
        		/*删除一个最高级的产品*/
        	     var brand = sessionStorage.getItem(3)
        	     console.log(brand) ; 			
        	     $http({
						method:'POST',	
						params:{brand_id:brand},				
						url: window.baseUrl+"user/thirdlevel/delete/thirdlevelid",
					}).then(function successCallback(data){
						console.log(data)
						console.log(data.data.resp_code)
						if(data.data.resp_code=="000000"){							
							alert(data.data.resp_message)
							 window.location.reload("pp01.html")
						}
						if(data.data.resp_code=="000001"){
							alert(data.data.resp_message)
							  window.location.reload("pp01.html")
						}
					}, function errorCallback(data) {
							console.log("查询所有三级分销产品失败...")
					     	console.log(data)
					}); 	
        	}
			
			$scope.hk = function(item){
				console.log(item)
				sessionStorage.setItem(15,item.id);
				sessionStorage.setItem(16,item.grade);
				sessionStorage.setItem(17,item.name);
				sessionStorage.setItem(18,item.money);
				sessionStorage.setItem(190,item.upgradestate);
				sessionStorage.setItem(200,item.earningsState);
			}
        	
        })
	</script>
</html>

